<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>3-FetchAPI响应数据格式</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <style></style>
  </head>
  <body>
    <div id="app"></div>
    <script>
      fetch('http://www.localhost:3000/json')
        .then(function (data) {
          return data.text();
        })
        .then(function (data) {
          console.log(data); // 转换前：json字符串
          var obj = JSON.parse(data);
          console.log(obj); // 转换后变成对象： {"uname":"zs","age":12}
        });
    </script>
  </body>
</html>
